/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javamail.web.util;

/**
 *
 * @author sriram
 */
public enum eParseRequest {
    NIL(0, "NIL"), POST(1, "POST"), GET(2, "GET");

    private final int index;
    private final String str;
    
    eParseRequest(int id, String string) {
        this.index = id;
        this.str = string;
    }
    
    public int toInt() {
        return index;
    }
 
    public String toString() {
        return str;
    }
 
    public static eParseRequest fromString(final String str) {
        for (eParseRequest opt : eParseRequest.values()) {
            if (opt.toString().equalsIgnoreCase(str)) {
                return opt;
            }
        }
        return NIL;
    }
 
    public static eParseRequest fromInt(final int index) {
        for (eParseRequest opt : eParseRequest.values()) {
            if (opt.index == index) {
                return opt;
            }
        }
        return NIL;
    }
}
